package com.sheng.center.action;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

public class AutoAction {
	
	public void Auto() {
	 Calendar calendar = Calendar.getInstance();
     Date firstTime = calendar.getTime();
     // 间隔：2分钟
     long period = 1000 * 2;//毫秒*数量，现在是2秒
     Timer timer = new Timer();
     timer.schedule(new TimerTask() {
         @Override
         public void run() {
             // 执行你的方法
        	 Date day = new Date();
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			System.out.println("==每两秒自动执行=="+df.format(day)+"\n");

         }
     }, firstTime, period);

}
	
}
